
import nonstd.reflection;
import nonstd.demangle;


struct S(a...)
{
}

extern(C) extern int errno;
template TypeTuple(T...) {}

alias S!(0.0L, 0x1.p-1050, 42 + 195i, "km", errno, TypeTuple) G;

ref int foo(in G s, out int o, ...) nothrow;

enum m = foo.mangleof;
//pragma(msg, m);

//pragma(msg, demangle(m));

pragma(msg, G.mangleof);
pragma(msg, demangle(G.mangleof));


int fooooo()
{
    // mangled function name
    enum fun = demangle("_D3std4math3sinFNaNbeZe");
    assert(fun == "pure nothrow real std.math.sin(real)");

    // mangled template instance name
    enum temp = demangle("3std10functional__T9binaryFunVAyaa3_612b62Z");
    assert(temp == `std.functional.binaryFun!("a+b")`);

    // mangled type name
    enum type = demangle("HAyai");
    assert(type == "string[int]");

    // not a valid D mangled name
    enum invalid = demangle("errno");
    assert(invalid == "errno");

    pragma(msg, fun);
    pragma(msg, temp);
    pragma(msg, type);
    pragma(msg, invalid);

    return 0;
}
enum aaa = fooooo();

